<template>
    <div id="background">
        <el-container>
            <el-header id="cstxHead">
                <el-row type="flex" style="height:80%;display:flex;align-items: flex-end">
                    <el-col :xs="2" :sm="2" :md="2" :offset="1"  class="imgCol">
                        <img v-bind:src="backIcon" class="backSize" @click="back" />
                    </el-col>
                    <el-col :xs="6" :sm="6" :md="6" :offset="6" class="imgCol">
                        <span class="titleSize">{{ceShiName+'测试'}}</span>
                    </el-col>
                </el-row>
            </el-header>
            <el-main id="cstxMain">
                <div class="tklx">
                <el-row v-for="ceShi in ceShiType" :key="ceShi.credentialId" >
                    <el-row type="flex" class="csbtn" >
                        <button class="tklxbtn" @click="goToExamIntroduce(ceShi.credentialId)" style="width: 80%;">
                            <span class="tklxBtnWords" >{{ceShi.name+'理论测试'}}</span>
                               <img :src="jianTou" class="jtImg" >
                        </button>
                    </el-row>
                </el-row>
                </div>
            </el-main>
        </el-container>
    </div>
</template>

<script>
import backIcon from '../../../assets/img/mine/back.png'
import jianTou from '../../../assets/img/tiKu/exam/jianTou.png'
export default {
     data(){
        return{
            //绑定传来的工种的id
            professionId:'',
            //绑定传过来的工种名称
            ceShiName:'',
            jianTou:jianTou,
            /**
             * {
            "name": "电工 初级理论测试",
            "credentialId": 1,
            "professionId": 1
                }
             */
            ceShiType:[],
            backIcon:backIcon,
            normalHeight:document.documentElement.clientHeight,
        }
    },
    mounted(){
        //获取对应工种id
        this.professionId=this.$route.query.professionId;
        this.ceShiName=this.$route.query.name;
        console.log(this.professionId+" "+this.ceShiName);
        
        this.getCeShiType();

        var normalHeight=sessionStorage.getItem('normalHeight');
        var bg = document.getElementById("background");
       // normalHeight=document.documentElement.clientHeight;
        console.log("height:"+normalHeight);
        bg.style.height = normalHeight+"px";
        bg.style.backgroundColor = "#FFFFFF"
        bg.style.margin = "0px";

        var head=document.getElementById("cstxHead");
        var headHeight=normalHeight/30 *4 ;
        console.log("headHeight:"+headHeight);
        head.style.height=headHeight+"px";

        var main=document.getElementById("cstxMain");
        var mainHeight=normalHeight/30 *26 ;
        main.style.height=mainHeight+"px";
    },
    methods:{
        back(){
            this.$router.go(-1);
        },
        goToExamIntroduce(id){
            this.$router.push({
                path:'/tiKu/examIntroduce',
                query:{
                    credentialId:id,
                    ceShiName:this.ceShiName
                }
            })
        },
        //获取对应测试类型
        getCeShiType(){
            var URL=this.IP.IP+'/questionBank/testsOfProfessionOf';
            console.log(URL);
            this.$ajax({
                method:'get',
                url:URL,
                params:{
                    professionId:this.professionId
                }
            }).then(response=>{
                console.log(response.data);
                var code=response.data.code;
                if(code==0){
                   this.ceShiType=response.data.data;
                }else{  
                    Toast(response.data.msg);
                }
            }).catch(error=>{
                console.log(error);
                //Toast(error);
            })
        }
    }
}
</script>

<style>
.el-main,.el-header,.el-footer,.el-aside{
    padding: 0px;
}
.jtImg{
    width:20px;
    height:10px;
}
.tklx{
    position: relative;
    top:15%;
}
.csbtn{
    display: flex;
    justify-content: center;
    align-items: center;
}
.tklxBtnWords{
    /* text-align: left; */
    font-size: 16px;
    font-weight: 400;
    color: #ffffff;
}
.tklxbtn{
    line-height: 40px;
    width: 80%;
    background-color: #53cdf5;
    border-style: none;
    outline: none;
    margin:15px;
    -webkit-border-radius: 25px;
    -moz-border-radius: 25px;
    -ms-border-radius: 25px;
    -o-border-radius: 25px;
    border-radius: 25px;
}
#cstxMain{
    padding:0;
    background: #FFFFFF;
}
#cstxHead {
  background-color: #53cdf5;
}
.backSize{
    height: 26px;
}
.titleSize{
    font-size:1.125em;
    color:#ffffff
}
@media screen and (max-height: 600px){
  .backSize{
      height: 22px;
  }
  .titleSize{
      font-size: 1em;
  }
}
</style>
